package process_demo.review.about_yield;

/**
 * @author haomin
 * @date 2022/09/09 09:43
 **/
public class Main {
    static class MyThread extends Thread {
        private final String name;
        public MyThread(String name) {
            this.name = name;
        }

        @Override
        public void run() {
            while (true){
                if(name.equals("张三")){
                    Thread.yield();
                }
                System.out.println("我是"+name);

            }
        }
    }

    public static void main(String[] args) {
        MyThread 张三 = new MyThread("张三");
        MyThread 李四 = new MyThread("李四");
        张三.start();
        李四.start();
    }
}